home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / +system+ / tools / gui / bgui.lha / bgui / Examples / Source / Colors.c < prev    next >
C/C++ Source or Header  |  2000-02-27  |  8KB  |  156 lines

  1. /*
  2.  * @(#) $Header: /cvsroot/bgui/examples/Attic/Colors.c,v 1.1.2.1 1998/02/28 17:45:01 mlemos Exp $
  3.  *
  4.  * Colors.c
  5.  *
  6.  * (C) Copyright 1998 Manuel Lemos.
  7.  * (C) Copyright 1995 Jaba Development.
  8.  * (C) Copyright 1995 Jan van den Baard.
  9.  * All Rights Reserved.
  10.  *
  11.  * $Log: Colors.c,v $
  12.  * Revision 1.1.2.1  1998/02/28 17:45:01  mlemos
  13.  * Ian sources
  14.  *
  15.  *
  16.  */
  17.  
  18. /* Execute me to compile with DICE V3.0
  19. dcc Colors.c -mi -ms -mRR -proto -lbgui
  20. quit
  21. */
  22.  
  23. #include "DemoCode.h"
  24.  
  25. /*
  26. **      Object ID's.
  27. **/
  28. #define ID_ALT                  1
  29. #define ID_QUIT                 2
  30.  
  31. VOID StartDemo( void )
  32. {
  33.         struct Window           *window;
  34.         Object                  *WO_Window, *GO_Quit, *GO_B[ 2 ], *GO_Alt;
  35.         ULONG                    signal, rc, tmp = 0, a;
  36.         BOOL                     running = TRUE;
  37.  
  38.         /*
  39.          *      Create the window object.
  40.          */
  41.         WO_Window = WindowObject,
  42.                 WINDOW_Title,           "Colors Demo",
  43.                 WINDOW_AutoAspect,      TRUE,
  44.                 WINDOW_SmartRefresh,    TRUE,
  45.                 WINDOW_RMBTrap,         TRUE,
  46.                 WINDOW_MasterGroup,
  47.                         VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), GROUP_BackFill, SHINE_RASTER,
  48.                                 StartMember,
  49.                                         InfoFixed( NULL, ISEQ_C "This small demo shows you how you can\n"
  50.                                                          "change the background and label colors\n"
  51.                                                          "of an object on the fly.\n\n"
  52.                                                          "As you can see the colors of the below buttons\n"
  53.                                                          "are normal but when the " ISEQ_B "Alternate" ISEQ_N " checkbox\n"
  54.                                                          "is selected the colors are changed.",
  55.                                                          NULL, 7 ),
  56.                                 EndMember,
  57.                                 StartMember,
  58.                                         HGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), FRM_Type, FRTYPE_BUTTON, FRM_Recessed, TRUE,
  59.                                                 StartMember, GO_B[ 0 ] = Button( "Colors", 0 ), EndMember,
  60.                                                 StartMember, GO_B[ 1 ] = Button( "Demo",   0 ), EndMember,
  61.                                         EndObject, FixMinHeight,
  62.                                 EndMember,
  63.                                 StartMember,
  64.                                         HGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), FRM_Type, FRTYPE_BUTTON, FRM_Recessed, TRUE,
  65.                                                 VarSpace( DEFAULT_WEIGHT ),
  66.                                                 StartMember, GO_Alt = KeyCheckBox( "_Alternate", FALSE, ID_ALT ), EndMember,
  67.                                                 VarSpace( DEFAULT_WEIGHT ),
  68.                                         EndObject, FixMinHeight,
  69.                                 EndMember,
  70.                                 StartMember,
  71.                                         HGroupObject,
  72.                                                 VarSpace( DEFAULT_WEIGHT ),
  73.                                                 StartMember, GO_Quit = KeyButton( "_Quit", ID_QUIT ), EndMember,
  74.                                                 VarSpace( DEFAULT_WEIGHT ),
  75.                                         EndObject, FixMinHeight,
  76.                                 EndMember,
  77.                         EndObject,
  78.         EndObject;
  79.  
  80.         /*
  81.         **      Object created OK?
  82.         **/
  83.         if ( WO_Window ) {
  84.                 /*
  85.                 **      Assign the keys to the buttons.
  86.                 **/
  87.                 tmp += GadgetKey( WO_Window, GO_Quit,  "q" );
  88.                 tmp += GadgetKey( WO_Window, GO_Alt,   "a" );
  89.                 /*
  90.                 **      OK?
  91.                 **/
  92.                 if ( tmp == 2 ) {
  93.                         /*
  94.                         **      try to open the window.
  95.                         **/
  96.                         if ( window = WindowOpen( WO_Window )) {
  97.                                 /*
  98.                                 **      Obtain it's wait mask.
  99.                                 **/
  100.                                 GetAttr( WINDOW_SigMask, WO_Window, &signal );
  101.                                 /*
  102.                                 **      Event loop...
  103.                                 **/
  104.                                 do {
  105.                                         Wait( signal );
  106.                                         /*
  107.                                         **      Handle events.
  108.                                         **/
  109.                                         while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
  110.                                                 /*
  111.                                                 **      Evaluate return code.
  112.                                                 **/
  113.                                                 switch ( rc ) {
  114.  
  115.                                                         case    WMHI_CLOSEWINDOW:
  116.                                                         case    ID_QUIT:
  117.                                                                 running = FALSE;
  118.                                                                 break;
  119.  
  120.                                                         case    ID_ALT:
  121.                                                                 /*
  122.                                                                  *      When the object is selected we use
  123.                                                                  *      alternate coloring on the objects.
  124.                                                                  *      If not we revert to default coloring.
  125.                                                                  */
  126.                                                                 GetAttr( GA_Selected, GO_Alt, &tmp );
  127.                                                                 /*
  128.                                                                  *      Setup the colors on the buttons.
  129.                                                                  */
  130.                                                                 for ( a = 0; a < 2; a++ )
  131.                                                                         SetGadgetAttrs(( struct Gadget * )GO_B[ a ], window, NULL,
  132.                                                                                 FRM_BackDriPen,                 tmp ? TEXTPEN  : (ULONG)~0,
  133.                                                                                 FRM_SelectedBackDriPen,         tmp ? SHINEPEN : (ULONG)~0,
  134.                                                                                 LAB_DriPen,                     tmp ? SHINEPEN : (ULONG)~0,
  135.                                                                                 LAB_SelectedDriPen,             tmp ? TEXTPEN  : (ULONG)~0,
  136.                                                                                 TAG_END );
  137.                                                                 break;
  138.                                                 }
  139.                                         }
  140.                                 } while ( running );
  141.                         } else
  142.                                 Tell( "Could not open the window\n" );
  143.                 } else
  144.                         Tell( "Could not assign gadget keys\n" );
  145.                 /*
  146.                 **      Disposing of the window object will
  147.                 **      also close the window if it is
  148.                 **      already opened and it will dispose of
  149.                 **      all objects attached to it.
  150.                 **/
  151.                 DisposeObject( WO_Window );
  152.         } else
  153.                 Tell( "Could not create the window object\n" );
  154. }
  155.  
  156.